import flask, math, json
from concurrent.futures import ProcessPoolExecutor

app = flask.Flask(__name__)

def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    sqrt_n = int(math.floor(math.sqrt(n)))
    for i in range(3, sqrt_n + 1, 2):
        if n % i == 0:
            return False
    return True

@app.route('/is_prime/<numbers>')
def api_is_prime(numbers):
    numbers = [int(x) for x in numbers.split(',')]
    results = list(pool.map(is_prime, numbers))

    return json.dumps(dict(zip(numbers, results)), ensure_ascii=False)

if __name__ == '__main__':
    pool = ProcessPoolExecutor()
    app.run()